using System.Collections.Generic;
using Newtonsoft.Json;
using Volo.Abp.Settings;
using Volo.Abp.Localization;
using Joy.Erp.BasicArchives.Core.UniqueCodes;
using Joy.Erp.BasicArchives.Localization;

namespace Joy.Erp.BasicArchives.ItemMasters
{
    internal class UnitSettingProvider : SettingDefinitionProvider
    {
        public override void Define(ISettingDefinitionContext context)
        {
            context.Add(
                new SettingDefinition(
                    $"UniqueCodeConfigration:{typeof(Unit).FullName}",
                    JsonConvert.SerializeObject(new UniqueCodeConfigrationObject
                    {
                        AutoCode = false,
                        SegmentConfigrations = new List<string>() {
                            $"SerialNumberSegment::{JsonConvert.SerializeObject(new SerialNumberSegmentConfigrationObject())}"
                        }
                    }),
                    L($"ModelSettingDisplayName:{typeof(Unit).FullName}.UniqueCodeConfigration"),
                    L($"ModelSettingDescription:{typeof(Unit).FullName}.UniqueCodeConfigration"),
                    isVisibleToClients: true
                )
            );
        }

        private static LocalizableString L(string name)
        {
            return LocalizableString.Create<BasicArchivesResource>(name);
        }
    }
}
